/* --- 颜色变量定义 --- */
:root {
    --sidebar-width-expanded: 220px;
    --sidebar-width-collapsed: 60px;
    --primary-color: #6366f1;
    --primary-hover-color: #4f46e5;
    --background-color: #111827;
    --container-bg-color: #1f2937;
    --input-bg-color: #374151;
    --text-color: #e5e7eb;
    --secondary-text-color: #9ca3af;
    --border-color: #4b5563;
    --success-color: #34d399;
    --error-color: #f87171;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 亮色主题变量 */
body.light-theme {
    --primary-color: #4f46e5;
    --primary-hover-color: #4338ca;
    --background-color: #f3f4f6;
    --container-bg-color: #ffffff;
    --input-bg-color: #ffffff;
    --text-color: #1f2937;
    --secondary-text-color: #6b7280;
    --border-color: #d1d5db;
    --success-color: #10b981;
    --error-color: #ef4444;
}

/* --- 全局布局 --- */
body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width-collapsed);
    background-color: var(--container-bg-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
}

#main-content {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
    height: 100%;
    overflow-y: auto;
    padding: 2rem;
    box-sizing: border-box;
}

#app-container.sidebar-expanded #sidebar {
    width: var(--sidebar-width-expanded);
}

/* --- 全局组件和基础元素样式 --- */

/* 侧边栏 (Sidebar) */
.sidebar-header {
    display: flex;
    align-items: center;
    padding: 0 18px;
    height: 60px;
    flex-shrink: 0;
    position: relative;
}
.sidebar-logo, .sidebar-logo-full {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}
.sidebar-logo { opacity: 1; }
.sidebar-logo-full { position: absolute; left: 18px; opacity: 0; }
#app-container.sidebar-expanded .sidebar-logo { opacity: 0; }
#app-container.sidebar-expanded .sidebar-logo-full { opacity: 1; }

#sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    right: -12px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background-color: var(--primary-color);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}
#app-container.sidebar-expanded #sidebar-toggle-btn .icon-arrow {
    transform: rotate(180deg);
}
.nav-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    flex-grow: 1;
}
.nav-item a {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 18px;
    text-decoration: none;
    color: var(--secondary-text-color);
    white-space: nowrap;
    overflow: hidden;
}
.nav-item a:hover {
    color: var(--text-color);
    background-color: color-mix(in srgb, var(--background-color) 50%, transparent);
}
.nav-item.active a {
    color: var(--primary-color);
    font-weight: 600;
    background-color: color-mix(in srgb, var(--primary-color) 15%, transparent);
    border-left: 3px solid var(--primary-color);
    padding-left: 15px;
}
.nav-item .icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}
.nav-label {
    margin-left: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
}
#app-container.sidebar-expanded .nav-label {
    opacity: 1;
    transition-delay: 0.1s;
}

/* 主题切换按钮 (Theme Toggle) */
#theme-toggle-btn {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background-color: var(--container-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}
#theme-toggle-btn:hover {
    border-color: var(--primary-color);
    transform: scale(1.1) rotate(15deg);
}
#theme-toggle-btn svg {
    color: var(--secondary-text-color);
    transition: all 0.3s ease;
}
#theme-toggle-btn:hover svg {
    color: var(--primary-color);
}
.light-icon { display: none; }
.dark-icon { display: block; }
body.light-theme .light-icon { display: block; }
body.light-theme .dark-icon { display: none; }


/* 通用基础元素 (h1, input, button, etc) */
.container {
    width: 100%;
    display: flex;
    flex-direction: column;
}
h1 {
    font-size: 2.25rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
}
.row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
input {
    flex-grow: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background-color: var(--input-bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
}
input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 30%, transparent);
}
#search-btn, #reset-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
#search-btn {
    color: white;
    background-color: var(--primary-color);
    border: none;
}
#search-btn:hover { background-color: var(--primary-hover-color); }
#search-btn:disabled { background-color: #4b5563; color: #9ca3af; cursor: not-allowed; }
#reset-btn {
    color: var(--secondary-text-color);
    background-color: transparent;
    border: 1px solid var(--border-color);
}
#reset-btn:hover { color: var(--text-color); border-color: var(--secondary-text-color); }

/* 全局浏览器样式覆盖 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    box-shadow: 0 0 0 1000px var(--input-bg-color) inset !important;
    -webkit-text-fill-color: var(--text-color) !important;
    border-color: var(--border-color) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* --- 新增：可复用的按钮变体 --- */

/* 次要按钮 (例如：浏览...) */
.secondary-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    color: var(--secondary-text-color);
    background-color: transparent;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}
.secondary-btn:hover {
    color: var(--text-color);
    border-color: var(--secondary-text-color);
}

/* 图标按钮 (例如：在文件夹中显示) */
.icon-btn {
    background: transparent;
    border: none;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: all 0.2s ease;
}
.icon-btn:hover {
    opacity: 1;
    background-color: var(--primary-color);
}
.icon-btn svg {
    width: 18px;
    height: 18px;
    color: var(--secondary-text-color);
    transition: color 0.2s ease;
}
.icon-btn:hover svg {
    color: white;
}

/* 页面内滚动条的专属样式 */
.results-container {
    background-color: var(--background-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    height: 60vh; /* 您可以根据需要调整高度 */
    overflow-y: auto;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.results-container::-webkit-scrollbar {
    width: 12px;
}
.results-container::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 10px;
}
.results-container::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
    border: 3px solid var(--background-color);
}
.results-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--secondary-text-color);
}